package com.wu.client.constant;

import com.wu.common.convertion.exception.ClientException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Cousin
 * @date 2025/3/16
 * @Description
 */
@AllArgsConstructor
@Getter
public enum ResTypeEnum {
    // contentType: "song" | "album" | "playlist" | "mv" | "comment" | "community"
    SONG("song",1),ALBUM("album",2),PLAYLIST("playlist",3),
    MV("mv",4),COMMENT("comment",5),COMMUNITY("community",6)
    ,ARTIST("artist",7),IMAGE("image",8);
    private final String type;
    private final Integer code;
    public static Integer getCodeByType(String type){
        for (ResTypeEnum value : ResTypeEnum.values()) {
            if (value.getType().equals(type)) {
                return value.getCode();
            }
        }
        throw new ClientException("资源类型传参错误："+type);
    }
    public static ResTypeEnum getByCode(Integer code){
        for (ResTypeEnum value : ResTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new ClientException("资源类型传参错误："+code);
    }
}
